home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
C
/
PASM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-14
|
3KB
|
108 lines
//#define DEBUG ;test file IO
//#define DEBUG2 ;test pasm
//#define DEBUG3 ;test readln
// PreASMmbler v1.2 32bit
// By:Peter Quiring
/*----------------------------------------------------------------------------
Version 1.20 NEW : handles single quotes into double quotes (you no longer
need to double them up yourself
Version 1.11 NEW : expand /t into tab
Version 1.10 NEW : no extra spaces between 'include' and 'file' were allowed
: major improvment in error handling
: \" will work now (use to have to use "" - which will still work)
: null strings now work
Version 1.04 NEW : Now the INCLUDE enviro str can have multiple paths
: seperated by ;
Version 1.03 NEW : 32bit using DOS32
: Buffered input/output (greatly increases speed!)
: \r=13, \n=10, \0=0 (\n use to =13,10)
Version 1.02 NEW : \0 will insert a ,0, into the string
Version 1.01 NEW : Now handles comment blocks
known bugs: v1.0
-none
known bugs: v0.1 ßeta
-can't not have ; or ' or " within quotes
Current version
limitations:
- Keeps all files open (until they are done), so you need a handle for
each file when there are includes...
future improvments:
-merge duplicate strings (now I could with 32bit power - so much RAM)
----------------------------------------------------------------------------*/
#include <qlib.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <fcntl.h>
#define mh 64 //max handles (the incs)
#define bufsiz 8*1024 //buffer size (BUG! make larger after debugging)
byte buf[256]; //current line
byte *bufo1;
byte *bufo2;
word bufp1,bufp2;
byte * bufin[mh];
word bufip[mh];
word bufis[mh];
byte buffn[mh][80];
word bufln[mh];
word cnum; //current string number
int ho1; // handle out for large ASM file (asm.tmp)
byte ho1on; //handle above has been created
int ho2; // handle out for special data segment! (_str_.tmp)
int h; // current file handle
int hs[mh]; // handles (all kept in place) (requires a lot of handles in config.sys)
byte ch; // current handle #
byte foundit; // flag to indicate we found #include!
byte EOFF[mh]; // flag (indicates that we have hit EOF)
//byte EOFF2[mh]; // flag (indicates that the current buffer is last one)
byte *file; //pts to filename to open
byte str[255];
byte str2[255];
byte str3[255];
byte enter[3]={13,10,0};
byte *inc; //INCLUDE name from enviroment
word incsiz; //size of inc string
byte t2[80];
byte anulstr;
void flush(void);
void prefile(void);
#include "err-p.h"
#include "readln.h"
#include "do.h"
#include "pasm.h"
void main(void) {
byte a;
printf("Pre Assembler v1.2 32bit (by : Peter Quiring)\n");
ho1on=0;
bufp1=0;
bufp2=0;
bufo1=(void *)malloc(bufsiz);
bufo2=(void *)malloc(bufsiz);
if ( ((dword)bufo1==ERROR) || ((dword)bufo2==ERROR) ) error("Out of RAM\n");
for(a=0;a<mh;a++) bufin[a]=0;
if (_argc!=2) error("Usage: PASM 'file.asm'");
file=_argv[1];
ch=(unsigned)255;
foundit=0;
cnum=0;
setup();
dofile();
flush();
if (!foundit) printf("Warning:'#include' was not found\n");
printf("Complete!\n\n");
exit(0);
}